<template>
	<header class="zfz-header">
		<div class="zfz-header-button is-left">
			<slot name='left'>
				<mt-cell icon='back' class='go-back'  @click.native="backPage">
				</mt-cell>
			</slot>
		</div>
		<h2 class="zfz-header-title" v-html='titleText'></h2>
		<div class="zfz-header-button is-right">
			<slot name='right'></slot>
		</div>
	</header>
</template>

<script>
	import { mapState, mapActions } from 'vuex'
	export default {
		name: 'zfz-header',
		props: {
			titleText: {
				type: String,
				default: 'Yami'
			}
		},
		//		props: ['tabBar', 'windowData'],
		data() {
			return {
				isShowIconBack: false,
				navigationBar: {
					navigationBarBackgroundColor: "	#000000",
					navigationBarTextStyle: "lightgrey",
					navigationBarTitleText: "测试",
					navigationBarRightIcon: null
				}
			}
		},
		mounted() {
		},
		created() {
			var currentRouter = this.$route.path;
			this.setIsShowIconBack(currentRouter)
		},
		watch: {  
			$route(to, from) {
				var path = to.path;
				var firstRouter = '/' + path.substr(1).split('/')[0]
//				this.setIsShowIconBack(firstRouter)  
			}
		},
		computed: {
			...mapState([
				'tabBar'
			]),
		},

		methods: {
			backPage(){
				console.log('back')
				this.$router.go(-1)
			},
			// 因底部tab栏 pagePath 设置的是一级路由 因此当前路由 需获取 一级路由名字进行设置
			setIsShowIconBack(path) {
//				var firstRouter = '/' + path.substr(1).split('/')[0]
//				var isShowIconBack = this.tabBar.list.filter((item) => {
//					if(item.pagePath === firstRouter) {
//						return item
//					}
//				}).length
//				if(isShowIconBack == 0) {
//					this.isShowIconBack = true
//				}
			}
		},
		filters: {}
	}
</script>
<style lang="scss">
.zfz-header-button {
	.go-back {
		/*height: 100%;*/
		.mint-cell-wrapper {
			padding-top: 10PX;
			padding-bottom: 10PX;
			.mintui-back {
				font-size: 40px;
				color: #000000;
			}			
		}
	}
}
</style>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang="scss">
	.zfz-header {
		position: fixed;
		left: 0;
		top: 0;
		right: 0;
		display: flex;
		align-items: center;
		height: 90px;
		border-bottom: 1px solid #dcdcdc;
		box-sizing: border-box;
		background-color: #FFFFFF;
		color: #4A4A4A;
		text-align: center;
		white-space: nowrap;
		z-index: 1000;
		.zfz-header-button {
			flex: 0.5;
			height: 90px;
			display: flex;
			align-items: center;
		}
		.zfz-header-title {
			text-align: center;			
			flex: 1;
			line-height: 90px;
			height: 90px;
			font-size: 30px;
			color: #333;
		}
		
	}
	.icon{
		width: 34px;
		height: 34px;
		display: inline-block;
	  background-repeat: no-repeat;
	  background-position: center;
	  background-size: cover; 
	}
	.icon-back{
		background-image: url(../../../static/img/iconback.svg);
	}
</style>